package files;


import java.io.File;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.*;
import java.nio.file.spi.FileSystemProvider;

public class DirectFile {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 1; i++) {
                    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(40960);
                    Path path = FileSystems.getDefault().getPath("/home/java","aaa.txt" );
                    try {
                        FileChannel fileChannel = FileChannel.open(path, StandardOpenOption.READ);
                        fileChannel.read(byteBuffer);
                        byteBuffer.flip();
                        byte[] bytes = new byte[byteBuffer.limit()];
                        byteBuffer.get(bytes);
                        String str = new String(bytes);
                        System.out.println(str);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

            }
        });
        thread.start();

    }
}
